package ua.kpi.fpm.km61.strat.sp.rules;

import java.util.HashSet;
import java.util.Set;

public class NonTerminal extends GramSymbol {

    private Set<Terminal> first = new HashSet<Terminal>();
    private Set<Terminal> follow = new HashSet<Terminal>();

    public NonTerminal() {
	super();
    }

    public NonTerminal(String name) {
	if (name.equals("START")) {
	    follow.add(new Terminal("$"));
	} else
	    this.setName(name);
    }

    public boolean isEps() {
	return first.contains((new Terminal("Eps")));
    }

    public boolean addFirst(Terminal term) {
	return first.add(term);
    }

    public boolean addFirst(NonTerminal nonTerm) {
	return first.addAll(nonTerm.getFirst());
    }

    public boolean addFollow(Set<Terminal> set) {
	set.remove(new Terminal("Eps"));
	return follow.addAll(set);
    }

    public Set<Terminal> getFirst() {
	return first;
    }

    public Set<Terminal> getFollow() {
	return follow;
    }

}
